package com.heima.listener;

import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

/**
 * @author :28169
 * @date : 2022/7/23 10:23
 */
@Component
public class TestListener {
    @KafkaListener(topics = "test-topic",groupId = "111")
    public void testListener(String message){
        if(!StringUtils.isEmpty(message)){
            System.out.println("执行");
            System.out.println(message);
        }


    }
    @KafkaListener(topics = "test-topic",groupId = "222")
    public void testListener1(String message){
        if(!StringUtils.isEmpty(message)){
            System.out.println("执行2");
            System.out.println(message);
        }
    }
    @KafkaListener(topics = "test-topic")
    public void testListener2(ConsumerRecord<String, String> record, Acknowledgment acknowledgment) {
        System.out.println(record.value());
        acknowledgment.acknowledge();
    }
}
